package WaiBao;

import java.util.Arrays;

public class ZhangYaNan {
    public static void main(String[] args) {
        String[] name = {"郭云静(班长)", "王玉华(副班长)", "小李(学习委员)", "李娇阳(体育委员)", "白子玉", "屈原", "张思文", "张倩倩", "翟依", "私信然", "长者", "王甜甜",
                "李佳伦", "张嘉伦", "刘浩存", "张哥哥", "王子玉", "凌耀东", "凌耀华", "林中会", "杨过", "白水", "李训", "马云", "李海", "王子腾", "雷军", "李俊哲",
                "林黛玉", "张雅楠(学生)"};//考生本人:张雅楠(学生))
        int[] age = {19, 21, 19, 19, 19, 20, 20, 21, 19, 19, 18, 19, 18, 20, 20, 19, 18, 21, 18, 18, 20, 19, 20, 20, 20, 18, 20, 18, 20, 19};//考生年龄：19

        double[] tanchun1 = {76, 86, 84, 84, 69, 69, 74, 80, 84, 84, 61, 84, 85, 80, 88, 68, 70, 70, 76, 84, 92, 91, 75, 65, 75, 74, 94, 87, 83, 96};
        double[] tanchun2 = {86, 84, 91, 76, 78, 74, 74, 74, 81, 74, 70, 77, 81, 80, 80, 64, 76, 79, 64, 98, 72, 71, 92, 82, 76, 84, 86, 76, 82, 96};
        double[] tanchun3 = {90, 76, 84, 85, 74, 66, 68, 74, 84, 80, 73, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 90, 76, 84, 74, 77, 89, 95};


        double shicai1;//代表每个学生的总分
        double shicai2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            shicai1 =tanchun1[i] + tanchun2[i] +tanchun3[i];
//            shicai2 = (shicai1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + shicai1);
//            System.out.println(name[i] + "的平均分为:" + shicai2);
//        }

//        double haiwai1 = 0,haiwai2 = 0;
//        double[] fengzhen = new double[30];
//        for (int i = 0; i < 30; i++) {
//            haiwai1=  tanchun1[i] +  tanchun2[i] +   tanchun3[i];
//            haiwai2 = (haiwai1* 1.0) / 3;
//            fengzhen[i] = haiwai2;
//        }
//
//        for (int i = 0; i < fengzhen.length - 1; i++) {
//            for (int j = 0; j <fengzhen.length - i - 1; j++) {
//                if (fengzhen[j] <fengzhen[j + 1]) {
//                    double tep = fengzhen[j];
//                    fengzhen[j] =fengzhen[j + 1];
//                    fengzhen[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(fengzhen[i]);
//        }



        double jingling1 = 0,jingling2 = 0,jingling3 = 0;//计算每门课的平均分
        double zhengze1 = 0,zhengze2 = 0,zhengze3 = 0;//计算每门课标准差
        double caizi1 = 0,caizi2 = 0,caizi3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <tanchun1.length; i++) {
            he +=tanchun1[i];
        }
        jingling1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + jingling1);
        double Sum = 0;
        for (int i = 0; i < tanchun2.length; i++) {
            Sum +=tanchun2[i];
        }
        jingling2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + jingling2);
        double sum = 0;
        for (int i = 0; i <tanchun3.length; i++) {
            sum +=tanchun3[i];
        }
        jingling3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + jingling3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <tanchun1.length; i++) {
            c1 += (tanchun1[i] -jingling1) * (tanchun1[i] - jingling1);
        }
        zhengze1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + zhengze1);
        for (int i = 0; i < tanchun2.length; i++) {
            c2 += (tanchun2[i] -jingling2) * (tanchun2[i] -jingling2);
        }
        zhengze2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +zhengze2);

        for (int i = 0; i <tanchun3.length; i++) {
            c3 += (tanchun3[i] -jingling3) * (tanchun3[i] -jingling3);
        }
        zhengze3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + zhengze3);
//////////////
        Arrays.sort(tanchun1);
        Arrays.sort(tanchun2);
        Arrays.sort(tanchun3);
        caizi1 = (tanchun1[14] +tanchun2[15]) * 1.0 / 2;
        caizi2 = (tanchun2[14] +tanchun2[15]) * 1.0 / 2;
        caizi3 = (tanchun3[14] +tanchun3[15]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + caizi1);
        System.out.println("农业设施设计与制造的中位数为:" + caizi2);
        System.out.println("园艺植物设施栽培学的中位数为:" + caizi3);




    }
}
